]> dgit.raspbian.org Git - gnome-shell.git/commitdiff
mixer-control: Use automatic cleanup in match_stream_with_devices
authorGuido Günther <agx@sigxcpu.org>
Sun, 4 Jan 2026 12:07:23 +0000 (13:07 +0100)
committerSimon McVittie <smcv@debian.org>
Wed, 28 Jan 2026 13:25:18 +0000 (13:25 +0000)
Simplifies the loop

Signed-off-by: Guido Günther <agx@sigxcpu.org>
Origin: https://gitlab.gnome.org/GNOME/libgnome-volume-control/-/merge_requests/31
Bug: https://gitlab.gnome.org/GNOME/libgnome-volume-control/-/issues/34
Bug-Debian: https://bugs.debian.org/1126514
Applied-upstream: gnome-shell 50, commit:798230599950607ec285daecd070f5bcb28580e4

Gbp-Pq: Topic libgvc
Gbp-Pq: Name mixer-control-Use-automatic-cleanup-in-match_stream_with_.patch

subprojects/gvc/gvc-mixer-control.c

index e326346a3445c28998ff25058161dd374a20c4ef..6d425ddba6d07e14e4c5ffff40f06340008c71e1 100644 (file)
@@ -1235,7 +1235,7 @@ match_stream_with_devices (GvcMixerControl    *control,
                            GvcMixerStreamPort *stream_port,
                            GvcMixerStream     *stream)
 {
-        GList                   *devices, *d;
+        g_autoptr (GList)        devices = NULL;
         guint                    stream_card_id;
         guint                    stream_id;
         gboolean                 in_possession = FALSE;
@@ -1245,12 +1245,12 @@ match_stream_with_devices (GvcMixerControl    *control,
 
         devices  = g_hash_table_get_values (GVC_IS_MIXER_SOURCE (stream) ? control->priv->ui_inputs : control->priv->ui_outputs);
 
-        for (d = devices; d != NULL; d = d->next) {
+        for (GList *d = devices; d != NULL; d = d->next) {
                 GvcMixerUIDevice *device;
                 guint             device_stream_id;
-                gchar            *device_port_name;
-                gchar            *origin;
-                gchar            *description;
+                g_autofree gchar *device_port_name = NULL;
+                g_autofree gchar *origin = NULL;
+                g_autofree gchar *description = NULL;
                 GvcMixerCard     *card;
                 guint             card_id;
 
@@ -1295,15 +1295,10 @@ match_stream_with_devices (GvcMixerControl    *control,
                         }
                 }
 
-                g_free (device_port_name);
-                g_free (origin);
-                g_free (description);
-
                 if (in_possession == TRUE)
                         break;
         }
 
-        g_list_free (devices);
         return in_possession;
 }